<template>
  <div>
    <h1>我是弟弟</h1>
    <p>{{ count }}</p>
    <button @click="unsubscribehandle">解绑</button>
  </div>
</template>

<script>
import PubSub from "pubsub-js";
export default {
  name: "Didi",
  data() {
    return {
      count: 0,
    };
  },
  created() {
    PubSub.subscribe("count", (a, data) => {
      this.count = data;
      console.log(a, data);

    });
  },
  methods:{
    unsubscribehandle(){
        PubSub.unsubscribe('count') //在接收方也可以解绑
    }
  }
};
</script>

<style>
</style>